//
//  LabelWithPicCell.m
//  趣·美食
//
//  Created by dllo on 15/9/28.
//  Copyright (c) 2015年 金旭. All rights reserved.
//

#import "LabelWithPicCell.h"


@interface LabelWithPicCell ()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, assign) BOOL isnight;
@end

@implementation LabelWithPicCell



- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
      
        self.imageView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageView];

        
        self.label = [[UILabel alloc] init];
        [self.contentView addSubview:self.label];
        self.label.textAlignment = NSTextAlignmentCenter;
        self.label.lineBreakMode = NSLineBreakByTruncatingMiddle;
        self.label.font = [UIFont systemFontOfSize:15];

        
    }
    
    return self;
}



- (void)setClassModel:(GFClassifyModel *)classModel {
    if (_classModel != classModel) {

        _classModel = classModel;
    }
    if (classModel.image_url) {
        [self.imageView setImageWithURL:[NSURL URLWithString:classModel.image_url] placeholderImage:[UIImage imageNamed:classModel.name]];
    }
    
    self.label.text = classModel.name;
    
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    
    self.imageView.frame = CGRectMake(ScreenWidth / 375 * 30, ScreenWidth / 375 * 20, ScreenWidth / 375 * 51, ScreenWidth / 375 * 51);
    
    self.label.frame = CGRectMake(ScreenWidth / 375 * 10, ScreenWidth / 375 * 80, ScreenWidth / 375 * 91, ScreenWidth / 375 * 20);
}

@end
